<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="24">
        <el-card class="update-log">
          <div slot="header" class="clearfix">
            <span>待办任务</span>
          </div>
          <div class="body">
            <el-table v-loading="loading" :data="todoList" border >
              <el-table-column label="任务编号" align="center" prop="taskId" :show-overflow-tooltip="true"/>
              <el-table-column label="流程名称" align="center" prop="procDefName"/>
              <el-table-column label="当前节点" align="center" prop="taskName"/>
              <el-table-column label="流程版本" align="center">
                <template slot-scope="scope">
                  <el-tag size="medium" >v{{scope.row.procDefVersion}}</el-tag>
                </template>
              </el-table-column>
              <el-table-column label="流程发起人" align="center">
                <template slot-scope="scope">
                  <label>{{scope.row.startUserName}} <el-tag type="info" size="mini">{{scope.row.startDeptName}}</el-tag></label>
                </template>
              </el-table-column>
              <el-table-column label="接收时间" align="center" prop="createTime" width="180"/>
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-edit-outline"
                    @click="handleProcess(scope.row)"
                  >处理
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-card>
      </el-col>

    </el-row>
    <el-divider />
    <!-- <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <el-card class="update-log">
          <div slot="header" class="clearfix">
            <span>流程自定义表单配置，文件、图片上传注意事项</span>
          </div>
          <p>①上传参数设置的上传地址必填：</p>
          <p>单文件上传：http://localhost:8080/common/upload<br>
          多文件上传：http://localhost:8080/common/uploads</p>
          <p>②.事件属性的onBeforeUpload必填：直接复制</p>
          <p>var currentWidget = this;<br>
            var token = getCookie("Admin-Token");<br>
            currentWidget.setUploadHeader('Authorization', 'Bearer ' + token);<br>
            // 获取token<br>
            function getCookie(cookieName) {<br>
            var strCookie = document.cookie;<br>
            var arrCookie = strCookie.split("; ");<br>
            for(var i = 0; i < arrCookie.length; i++){<br>
            var arr = arrCookie[i].split("=");<br>
            if(cookieName == arr[0]){<br>
            return arr[1];<br>
            }}return "";}</p>
          <p>③.事件属性的onUploadSuccess必填：直接复制</p>
          <p>return{<br>
            'name' : result.newFileName,<br>
            'url' : result.url,<br>
            }
          </p>

        </el-card>
      </el-col>

    </el-row> -->
  </div>
</template>

<script>
import {todoList} from "@/api/flowable/todo";

export default {
  name: "index",
  data() {
    return {
      // 版本号
      version: "3.4.0",
      // 流程待办任务表格数据
      todoList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        category: null
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },

    /** 查询流程定义列表 */
    getList() {
      this.loading = true;
      todoList(this.queryParams).then(response => {
        this.todoList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 跳转到处理页面
    handleProcess(row){
      this.$router.push({ path: '/flowable/task/todo/detail/index',
        query: {
          procInsId: row.procInsId,
          executionId: row.executionId,
          deployId: row.deployId,
          taskId: row.taskId,
          taskName: row.taskName,
          startUser: row.startUserName + '-' + row.startDeptName,
        }})
    },
  },
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

